/**
 * 
 */
package edu.scsu.csci.config;

import java.lang.annotation.Annotation;

import edu.scsu.csci.IValidator;
import edu.scsu.csci.util.ReflectionUtil;
import edu.scsu.csci.validator.TypeAnnotationRegistry;
import edu.scsu.csci.validator.ValidatorAnnotationRegistory;

/**
 * 
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see
 * @viz.diagram ConfigValidatorWrapper.tpx
 */
public class ConfigValidatorWrapper implements Item {
	/**
	 * the type of objects the convertor is capable of converting.
	 */
	private Class<?> objectType;

	/**
	 * the implemtaion for the convetor.
	 */
	private Class<? extends IValidator> validatorClazz;

	/**
	 * annotaion
	 */
	private Class<? extends Annotation> annotaionClazz;

	/**
	 * 
	 */
	public ConfigValidatorWrapper() {
	}

	/**
	 * @param objectType
	 * @param convertorClazz
	 * @param annotaionClazz
	 */
	public ConfigValidatorWrapper(Class<?> objectType,
			Class<? extends IValidator> convertorClazz,
			Class<? extends Annotation> annotaionClazz) {
		this.objectType = objectType;
		this.validatorClazz = convertorClazz;
		this.annotaionClazz = annotaionClazz;
	}

	/**
	 * Returns convertorClazz.
	 * 
	 * @return Returns convertorClazz.
	 */
	public Class<? extends IValidator> getValidatorClazz() {
		return validatorClazz;
	}

	/**
	 * @param convertorClazz
	 *            The convertorClazz to set.
	 */
	public void setValidatorClazz(Class<? extends IValidator> validatorClazz) {
		this.validatorClazz = validatorClazz;
	}

	/**
	 * Returns type.
	 * 
	 * @return Returns type.
	 */
	public Class<?> getObjectType() {
		return objectType;
	}

	/**
	 * @param type
	 *            The type to set.
	 */
	public void setObjectType(Class<?> type) {
		this.objectType = type;
	}

	public void register() throws ConfigurationException {
		TypeAnnotationRegistry.getInstance().register(this.objectType,
				this.annotaionClazz);
		ValidatorAnnotationRegistory.getInstance().register(
				this.annotaionClazz,
				ReflectionUtil.instantiate(this.validatorClazz));
	}

	/**
	 * Returns annotaionClazz.
	 * 
	 * @return Returns annotaionClazz.
	 */
	public Class<? extends Annotation> getAnnotaionClazz() {
		return annotaionClazz;
	}

	/**
	 * @param annotationClazz
	 *            The annotaionClazz to set.
	 */
	public void setAnnotaionClazz(Class<? extends Annotation> annotationClazz) {
		this.annotaionClazz = annotationClazz;
	}
}
